home *** CD-ROM | disk | FTP | other *** search
- #include <GestaltEqu.h>
- #include <Traps.h>
- //
- // According to the Macintosh Technical Notes (PT 535-MacsBug Q&As) we have:
- //
- // ================================ citation start ================================
- // The MacsBug debugger is loaded into high memory above the value found in the
- // global variable BufPtr ($10C). Since it’s loaded into the memory that’s not
- // managed by the Memory Manager, it’s not in a heap. The global variable MacJmp
- // ($120) points to the debugger’s entry point.
- //
- // There’s also a flags byte in low memory that contains the following information:
- //
- // Bit 7 Set if debugger is running.
- // Bit 6 Set if debugger can handle system errors.
- // Bit 5 Set if debugger is installed.
- // Bit 4 Set if debugger can support the Discipline utility.
- //
- // The flags byte may be in one of two places: the high-order byte of the long word
- // at MacJmp, or the address $BFF. When MacsBug is loaded, it examines the value at
- // address $BFF. If the value at $BFF is $FF, the system is using the 24-bit Memory
- // Manager and the flags byte will be the high-order byte of the long word at MacJmp.
- // If the value at $BFF isn’t $FF, the system is using the 32-bit Memory Manager and
- // the flags byte will be at address $BFF.
- //
- // For information on debuggers other than MacsBug, you’ll need to contact the
- // publishers of those products.
- // ================================= citation end =================================
- //
- // Thus, one would expect that
- //
- // "Debugger present <=> (MacJmp != 0)".
- //
- // On a Mac IIx with 8MB RAM, however, MacJmp contained the value '0x80000000' when
- // MacsBug was not installed. If MacsBug was installed it seemed to contain the
- // address of an entry point to MacsBug. Therefore we use a slightly different
- // way to detect the presence of MacsBug:
- //
- // "Debugger present <=> ((MacJmp & 0x0FFFFFFF) != 0)"
- //
- #define MacJmp 0x120
-
- void main()
- {
- asm
- {
- move.l MacJmp,D0
- and.l #0x7FFFFFFF,D0
- beq.s @noDebuggerPresent
- dc.w _Debugger
- rts
-
- noDebuggerPresent:
- move.w #0x09,-(sp)
- dc.w _SysBeep
- // rts automatically included at end by Think C
- }
- }
-